#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Last Update:

'''多个选项的筛选使用, P84
'''

OPTIONS = {}
def register_option(name):
    return OPTIONS.setdefault(name, 1<<len(OPTIONS))

def has_option(options, name):
    return bool(options & name)

BLUE = register_option('BLUE')
RED = register_option('RED')
WHITE = register_option('WHITE')

SET = BLUE | RED
print BLUE, RED, WHITE
print SET

print has_option(SET, BLUE)
print has_option(SET, WHITE)

